package cn.hongsw.file.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author :hongsw
 * @date :2021-08-11 14:49
 */
@RestController
public class UploadController {
    @PostMapping("upload")
    public String upload(MultipartFile file) throws IOException {
        File localFile = new File("E:\\" + file.getOriginalFilename());
        if (localFile.createNewFile()) {
            file.transferTo(localFile);
        }
        return "上传完成";
    }
}
